<!DOCTYPE html>
<html>
<body>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script type="text/javascript">
var test = async_test("Let XMLHttpRequest with responseType set to json handle non-UTF-8 file.");

test.step(function()
{
    var xhr = new XMLHttpRequest;

    xhr.responseType = "json";
    assert_equals(xhr.responseType, "json", "xhr.responseType");

    xhr.onreadystatechange = test.step_func(function()
    {
        if (xhr.readyState != 4)
            return;

        assert_equals(xhr.status, 200, "xhr.status");
        assert_equals(xhr.response, "\uFFFD", "xhr.response");
        test.done();
    });

    xhr.open('GET', 'resources/invalid-utf8-json.pl', true);
    xhr.send();
});
</script>
</body>
</html>
